package com.corona.game.util;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.corona.game.util.texture.TilesAtlas;

/* loaded from: pokewilds.jar:com/pkmngen/game/util/SmolSprite.class */
public class SmolSprite extends TextureRegion {
    private float x;
    private float y;
    public static Color prevColor = new Color();
    private int offsetX;
    private int offsetY;

    public SmolSprite() {
        this.offsetX = 0;
        this.offsetY = 0;
    }

    public SmolSprite(Texture texture) {
        this(texture, 0, 0, texture.getWidth(), texture.getHeight());
    }

    public SmolSprite(Texture texture, int srcWidth, int srcHeight) {
        this(texture, 0, 0, srcWidth, srcHeight);
    }

    public SmolSprite(Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) {
        this.offsetX = 0;
        this.offsetY = 0;
        if (texture == null) {
            throw new IllegalArgumentException("texture cannot be null.");
        }
        setTexture(texture);
        setRegion(srcX, srcY, srcWidth, srcHeight);
    }

    public SmolSprite(TextureRegion region) {
        this.offsetX = 0;
        this.offsetY = 0;
        setRegion(region);
    }

    public SmolSprite(TextureAtlas.AtlasRegion atlasRegion) {
        this((TextureRegion) atlasRegion);
        this.offsetX = atlasRegion.getRegionX();
        this.offsetY = atlasRegion.getRegionY();
    }

    @Override // com.badlogic.gdx.graphics.g2d.TextureRegion
    public void setRegion(int x, int y, int width, int height) {
        setRegion(x + this.offsetX, y + this.offsetY, width, height);
    }

    public void setRegion(TextureAtlas.AtlasRegion atlasRegion) {
        setRegion((TextureRegion) atlasRegion);
        this.offsetX = atlasRegion.getRegionX();
        this.offsetY = atlasRegion.getRegionY();
    }

    @Override // com.badlogic.gdx.graphics.g2d.TextureRegion
    public void setRegionX(int x) {
        setRegionX(x + this.offsetX);
    }

    @Override // com.badlogic.gdx.graphics.g2d.TextureRegion
    public void setRegionY(int y) {
        setRegionY(y + this.offsetY);
    }

    public void draw(Batch batch) {
        batch.draw(this, this.x, this.y);
    }

    public void setPosition(float x, float y) {
        this.x = x;
        this.y = y;
    }

    @Override // com.badlogic.gdx.graphics.g2d.TextureRegion
    public Texture getTexture() {
        return getTexture();
    }

    public Pixmap getPixmap() {
        Texture texture = getTexture();
        Pixmap originalPixmap = TilesAtlas.getAtlasPixmap(texture);
        if (originalPixmap == null) {
            TextureData textureData = texture.getTextureData();
            if (!textureData.isPrepared()) {
                textureData.prepare();
            }
            originalPixmap = textureData.consumePixmap();
        }
        return originalPixmap;
    }

    public float getX() {
        return this.x;
    }

    public float getY() {
        return this.y;
    }

    public float getWidth() {
        return (float) getRegionWidth();
    }

    public float getHeight() {
        return (float) getRegionHeight();
    }

    public void translateX(float xAmount) {
        this.x += xAmount;
    }

    public void translateY(float yAmount) {
        this.y += yAmount;
    }

    public void draw(Batch batch, float alphaModulation) {
        prevColor.set(batch.getColor());
        batch.setColor(prevColor.r, prevColor.g, prevColor.b, alphaModulation);
        draw(batch);
        batch.setColor(prevColor);
    }
}
